//
// Created by Administrator on 24-8-10.
//

#include "Flame.h"

Flame::Flame(GPIO_TypeDef *port, uint16_t pin) {
    //初始化端口
    this->m_Flame_Port=port;
    this->m_Flame_Pin=pin;
    //安全
    m_stat=STATE::SAFETY;
}

STATE Flame::FlameCheck() {

    /**
     * 持续读入火焰传感器的数据，一旦发现就报警
     */
    if(HAL_GPIO_ReadPin(this->m_Flame_Port,this->m_Flame_Pin)==GPIO_PIN_SET){
        //读取到高电平则需要返回危险
        m_stat=STATE::DANGER;
    }else{
        m_stat=STATE::SAFETY;
    }
    return m_stat;
}
